/**
 * @file test_for_hash.h
 * @version V0.01
 * @brief 《嵌入式软件开发笔记》中的关于 # 和 ## 的用法测试
 * @brief # 字符串化操作符 ## 符号连接操作符
 * @author 陈吉
 * @date 2024-08-29
 * @copyright Copyright (c) 2024, chenji 
 * All rights reserved.
 */
#ifndef TEST_FOR_HASH_H
#define TEST_FOR_HASH_H

#include <stdio.h>
#include <stdint.h>
#include <string.h>

/**
 * @brief # 字符串化操作符
 * @brief ## 符号连接操作符
 */

#define example( insr ) #insr
#define STRCPY(a, b) strcat(a, #b)
#define example2( n ) num##n


#define A 2
#define _STR( s ) #s
#define STR( s ) _STR( s ) // 转换宏

#define _CONS(a, b) a##e##b
#define CONS(a, b) _CONS(a, b) // C语言整数的科学计数法表示


typedef void (*os_pthread) (void const *argument);

typedef enum  {
  osPriorityIdle          = -3,          ///< priority: idle (lowest)
  osPriorityLow           = -2,          ///< priority: low
  osPriorityBelowNormal   = -1,          ///< priority: below normal
  osPriorityNormal        =  0,          ///< priority: normal (default)
  osPriorityAboveNormal   = +1,          ///< priority: above normal
  osPriorityHigh          = +2,          ///< priority: high
  osPriorityRealtime      = +3,          ///< priority: realtime (highest)
  osPriorityError         =  0x84        ///< system cannot determine priority or thread has illegal priority
} osPriority;

typedef struct os_thread_def  {
  char                   *name;        ///< Thread name 
  os_pthread             pthread;      ///< start address of thread function
  osPriority             tpriority;    ///< initial thread priority
  uint32_t               instances;    ///< maximum number of instances of that thread function
  uint32_t               stacksize;    ///< stack size requirements in bytes; 0 is default stack size
} osThreadDef_t;

//参考 STM32 的 cmsis_os.h 中的宏定义，表示 # 和 ## 的经典用法
#define osThreadDef(name, thread, priority, instances, stacksz)  \
const osThreadDef_t os_thread_def_##name = \
{ #name, (thread), (priority), (instances), (stacksz)}

void test_for_hash(void);

#endif